package com.tledu.web04.filter;

import javax.servlet.*;
import java.io.IOException;


public class EncodingFilter implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    @Override
    public void doFilter(ServletRequest req, ServletResponse res, FilterChain filterChain) throws IOException, ServletException {
        System.out.println("字符编码的过滤器");
        req.setCharacterEncoding("utf-8");
        res.setCharacterEncoding("utf-8");
        // 指定这一行代码就代表要执行后续的请求了
        filterChain.doFilter(req, res);
    }

    @Override
    public void destroy() {

    }
}
